//
//  MTFindView.m
//  met
//
//  Created by 李晓俊 on 2019/5/14.
//  Copyright © 2019 李晓俊. All rights reserved.
//

#import "MTFindView.h"

@implementation MTFindView
{
    
    CGRect myframe;

   
}
- (MTFindView  *)initWithFrame:(CGRect)frame

{
    self = [super initWithFrame:frame];
    if (self) {
        NSArray *nibs=[[NSBundle mainBundle]loadNibNamed:@"MTFindView" owner:nil options:nil];
        self=[nibs objectAtIndex:0];
        myframe = frame;
    }
    return self;
}
-(void)drawRect:(CGRect)rect

{
    self.frame=myframe;//关键点在这里
}

- (void)setModel:(FindModel *)model {
    _model = model;
//    self.costLabel.text = [NSString stringWithFormat:@"%@",model.];
    self.name.text = [NSString stringWithFormat:@"%@",model.nickName];
    self.address.text = @"";
//    [NSString stringWithFormat:@"%@",model.nickName];
    
    if ([[NSString stringWithFormat:@"%@",model.createType] isEqualToString:@"1"]) {
        //用户
        self.homeBut.hidden = NO;
    }else {
        self.homeBut.hidden = YES;
    }

    NSString *unit = @"m";
    NSString *distance = @"0";
    if ([[NSString stringWithFormat:@"%@",model.distance] integerValue] > 1000) {
        unit = @"km";
        double juli = [[NSString stringWithFormat:@"%@",model.distance] integerValue] / 1000.0;
        distance = [NSString stringWithFormat:@"%.2f",juli];
    }else {
        distance = [NSString stringWithFormat:@"%@",model.distance];
    }
    
    self.distance.text = [NSString stringWithFormat:@"%@",distance];
    //单位
    self.unit.text = [NSString stringWithFormat:@"%@",unit];
    
    
    NSString *sex = @"";
    if ([[NSString stringWithFormat:@"%@",model.sex] isEqualToString:@"1"]) {
        sex = @"男";
    }else {
        sex = @"女";
    }
    self.sex.text = sex;
    self.count.text = [NSString stringWithFormat:@"%@",model.storyNum];
    
    if ([[NSString stringWithFormat:@"%@",model.isMutual]isEqualToString:@"1"]) {
        //已经关注了
        self.liaotaBut.hidden = YES;
        self.siliaoBut.hidden = NO;
//        self.costLabel.hidden = YES;
    }else {
        self.liaotaBut.hidden = NO;
        self.siliaoBut.hidden = YES;
//        self.costLabel.hidden = NO;
    }
}
@end
